﻿using System;
using System.Collections.Generic;
using System.Text;

using System.Data;
using System.Data.SqlClient;
using MyHotel_DTO;
using MyHotel_Common;


namespace MyHotel_DAO
{
    public class ThanhToanDAO : DAO
    {
        protected override object createObjectFromDatarow(DataRow row)
        {
            ThongTinThanhToan tttt = new ThongTinThanhToan();
            tttt.Tenphong = row["TenPhong"].ToString();
            tttt.Songaythue = Convert.ToInt32(row["Songaythue"].ToString());
            tttt.Dongia = Convert.ToInt32(row["Dongia"].ToString());
            tttt.Thanhtien = (float)Convert.ToDouble(row["Thanhtien"].ToString());
            return tttt;
        }
        
        public ThongTinThanhToan getThongTinThanhToan(int maphong)
        {
            string namestore = "usp_LayThongTinThanhToan";
            SqlParameter para  = new SqlParameter("@Maphong", maphong); 
            DataTable dt = DataProvider.executeStoreProcedureQuery(namestore, para);
            return (ThongTinThanhToan)createObjectFromDatarow(dt.Rows[0]);
        } 
        public int ThanhToanPhong(int maphong, float sotien)
        {
            string nameProc = "usp_ThanhToanPhong";
            SqlParameter[] para = new SqlParameter[2];
            para[0] = new SqlParameter("@maphong", maphong);
            para[1] = new SqlParameter("@sotien", sotien); 
            return DataProvider.executeStoreProcedureNonQuery(nameProc, para); 
        } 
    }
}
